package com.qihoo.finance.fake;

import com.google.gson.Gson;
import com.qihoo.finance.msf.api.dc.domain.InstanceDomain;
import org.junit.Test;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class ToJsonMain {

    @Test
    public void test_instanceDomain_tojson(){
        InstanceDomain instanceDomain = new InstanceDomain();
        instanceDomain.setNo(0);
        instanceDomain.setName("fake-app");
        instanceDomain.setHost("");
        instanceDomain.setPort(0);
        instanceDomain.setState("");
        instanceDomain.setGrayFlag("");
        instanceDomain.setMsfVersion("");

        System.out.println(new Gson().toJson(instanceDomain, InstanceDomain.class));

    }


    @Test
    public void test_parse_double(){
        Object o1 = 100;
        long value1 = new Double(String.valueOf(o1)).longValue();
        System.out.println(value1);

        Object o2 = 100.01;
        long value2 = new Double(String.valueOf(o2)).longValue();
        System.out.println(value2);
    }


    @Test
    public void test_timestamp() throws ParseException {
        Date date = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse("2099-12-31 23:59:59");
        System.out.println(date.getTime());
    }


}
